package com.project.yuepai.controller.admin;

import com.project.yuepai.model.Admin;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/admin")
public class AdminPageJumpController {

    @GetMapping("/login")
    public String toLogin(){
        return "admin-login";
    }

    @GetMapping("/index")
    public ModelAndView toIndex(ModelAndView modelAndView,HttpSession session){

        if(session.getAttribute("admin")==null){
            modelAndView.setViewName("admin-login");
            return modelAndView;
        }
        Admin admin = (Admin) session.getAttribute("admin");
        modelAndView.addObject("admin",admin);
        modelAndView.setViewName("admin-index");
        return modelAndView;
    }

    @GetMapping("/user-manage")
    public String toUserManage(HttpSession session){
        if(session.getAttribute("admin")==null)
            return "404";
        return "user-manage";
    }

    @GetMapping("/dynamic-manage")
    public String toDyanmicManage(HttpSession session){
        if(session.getAttribute("admin")==null)
            return "404";
        return "dynamic-manage";
    }

    @GetMapping("/order-manage")
    public String toOrderManage(HttpSession session){
        if(session.getAttribute("admin")==null)
            return "404";
        return "order-manage";
    }

    @GetMapping("/feedback-list")
    public String toFeedbackList(HttpSession session){
        if(session.getAttribute("admin")==null)
            return "404";
        return "feedback-list";
    }

    @GetMapping("/welcome")
    public String toWelcome(HttpSession session){
        if(session.getAttribute("admin")==null)
            return "404";
        return "welcome-admin";
    }

    @GetMapping("/order-list")
    public String toOrderList(HttpSession session){
        if(session.getAttribute("admin")==null)
            return "404";
        return "order-list";
    }

    @GetMapping("/feedback-content")
    public String toFeedbackContent(){
        return "feedback-content";
    }

    @GetMapping("/dynamic-content")
    public String toDynamicContent(){
        return "dynamic-content";
    }

    @GetMapping("/dynamic-images")
    public String toDynamicImages(){
        return "dynamic-images";
    }




}
